Skip to content

fix(ios): keyboard dismiss never presses the return key - #4644

Merged
thymikee merged 20 commits into
mainfrom
t3/ios-keyboard-dismiss-return-key
Nov 18, 2026
Merged

thymikee merged 20 commits into
mainfrom
t3/ios-keyboard-dismiss-return-key

Conversation

@thymikee

@thymikee thymikee commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

keyboard dismiss on iOS pressed a return key labelled "Done" as if it were a dismiss key, so the form submitted. RunnerKeyboardStatus.returnControl now decides which key is the return key. keyboard status reports it and keyboard dismiss excludes it. The iPad hide-keyboard key and a "Done" toolbar above the keys stay dismiss keys. With no other dismiss key, dismiss refuses with keyboard_dismiss_unavailable (dispatched: no). keyboard enter still submits.

10 files. The iOS e2e now asserts the refusal and uses keyboard enter where it needed the field's submit to hide the keyboard. Help and commands.md say dismiss never presses the return key. Closes #4640.

Validation

Device: iPhone Air simulator, iOS 27.0 (1B89356B-961C-4993-B0BE-4C0F3917D995), Wallet sign-up, focus in the password field (keyboard status: returnKey: done).

  • Base 1cb2f242ae: keyboard dismiss → dismissed: true, mechanism: dismissKey; app lands on Home ("Hi, Review").
  • Head fc45a008b3: keyboard dismiss → success: false, KEYBOARD_DISMISS_UNAVAILABLE, reason: keyboard_dismiss_unavailable, dispatched: "no". The sign-up form stays, the password field is [focused], and keyboard status still reports the keyboard visible.
  • Name field (returnKey: next): refuses the same way at base and head.
  • Runner XCUITests on that simulator, 6 of 6 pass: testKeyboardDismissNeverPressesADoneReturnKey, testKeyboardDismissPressesTheDoneToolbarNotTheDoneReturnKey, testKeyboardDismissTapsItsDismissKeyWhileTheAppIsBusy, testKeyboardEnterPressesReturnWhileTheAppIsBusy, and two pure return-key tests. With the exclusion disabled, the first two fail.
  • Local: focused vitest, pnpm typecheck, pnpm lint, pnpm check:xctest-selection pass. The full gate is left to CI.

Risk: the iOS simulator e2e edit in live-runner.ts was not run live.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.37 MB 6.38 MB +5.4 kB
Package (unpacked) 6.37 MB 6.38 MB +5.4 kB
Package (download) 1.93 MB 1.94 MB +1.3 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 37.6 ms 44.2 ms +6.7 ms
CLI --help 75.2 ms 107.7 ms +32.5 ms

@thymikee

Copy link
Copy Markdown
Member Author

The change needs one more fix before merge: keyboard dismiss is still used on iOS routes where the only Done key is the return key (reviewed at 8ae4c31).

The replay 02-checkout-release.ad:12 fills field-email and then runs keyboard dismiss. That field has returnKeyType="done" and no input accessory (FormScreen.tsx:116-125), so dismiss now refuses with keyboard_dismiss_unavailable. The PR's own live-runner.ts:350-361 asserts that refusal on the same field. The iOS e2e runs this replay through assertFixtureReplays, so I expect that step to fail. The same unconverted step is in the shipped example checkout-form.ad:11 and in the iOS perf form step (suite.ts:304-308), and the comment at perf-nightly.yml:117 still says dismiss finds that Done key. The rule is that no iOS script may expect keyboard dismiss to succeed on a field whose only Done is its return key. Please grep keyboard dismiss and ['keyboard','dismiss'] across test/, examples/ and scripts/perf, and for each iOS route on field-email use keyboard enter (or expect the refusal). The test-app copy in FormScreen.tsx:104 and examples/test-app/README.md:17 should match.

Not blocking, take or leave: the strings in live-runner.ts around :379 and :419 (the comment, the step name "read email after dismiss", "should survive keyboard dismiss", "capture dismissed input keyboard", "dismissal changed pixels") still describe a dismiss that no longer happens; the help text in command-surface system/index.ts:322 now reads "... remain dismiss keys. Use enter or return to submit. and reports UNSUPPORTED_OPERATION ...", so move that sentence after the UNSUPPORTED_OPERATION clause; and in RunnerKeyboardStatus.swift:118, returnControl takes the first worded control across keys then buttons, so if an accessory toolbar shows up under app.keyboards with a "Next" button indexed before the return key, it could name the toolbar instead of the real Done key. Could the accessory XCUITest assert keyboardStatus(app: app).returnKey == "done" plus an isReturnControl check, and restrict candidates to the key rows if the toolbar is observed?

CI is still pending: all 15 non-passing jobs are queued or in progress, with no failure yet. Smoke Tests (ios) runs the changed assertFormInput and the checkout replay above, so it is the check to watch. Whether iOS 27 exposes an accessory toolbar under app.keyboards is not confirmed yet. There are no conflicts. Before merge, the remaining iOS keyboard dismiss steps on field-email need converting so Smoke Tests (ios) can pass.

@thymikee

Copy link
Copy Markdown
Member Author

Pushed 05f4467, addressing the review at 8ae4c31.

Required: iOS routes that dismissed on field-email

  • 02-checkout-release.ad and examples/test-app/replays/checkout-form.ad now run keyboard enter. The field's onSubmitEditing calls Keyboard.dismiss(), so the keyboard hides and focus does not move. The later steps are unchanged.
  • scripts/perf/suite.ts: the form step is now keyboard-hide. It runs keyboard enter on iOS and keeps keyboard dismiss on Android, whose headless IME has no Done key. The perf-nightly.yml comment, FormScreen.tsx and examples/test-app/README.md match. The Android replays are unchanged.

Optional items, applied

  • The live-runner.ts step names, assertions and comments no longer say a dismiss happens.
  • In the keyboard help, the UNSUPPORTED_OPERATION clause now comes before the "never presses the return key" sentence.
  • returnControl ignores a named control that sits wholly above the first row of character keys, so an accessory toolbar's Next or Done is never the return key. A new unit test covers a phone with a toolbar Next and a pad whose only Done is a toolbar button. The accessory XCUITest now asserts keyboardStatus.returnKey == "done" and that exactly one of the two Done buttons is the return control.
  • On this iOS 27.0 simulator, app.keyboards does not expose the accessory toolbar. The guard is positional and does not depend on that. The space bar's label here is space, not a blank, so the slot rule does not apply here; wording names the key.

Verification (iPhone Air simulator, iOS 27.0, 1B89356B, branch CLI, Agent Device Tester)

  • 02-checkout-release.ad: replayed 19 steps in 32.9s. The same script with keyboard dismiss fails at step 7 with keyboard_dismiss_unavailable.
  • checkout-form.ad: replayed 19 steps in 14.9s.
  • Runner tests on the simulator: all 20 in RunnerTests+KeyboardReturnKeyTests.swift pass, plus the four keyboard device tests (two new dismiss tests, two busy-keyboard tests). 0 failures.
  • Local: focused vitest (149 files), typecheck, lint and check:native-dupes pass (60 clones, none new). The iOS Smoke Tests job is the remaining check.

thymikee and others added 5 commits November 17, 2026 17:13
One owner (RunnerKeyboardStatus.returnControl) decides which keyboard key is the
return key. keyboard status reports it and keyboard dismiss excludes it, so a
return key labelled Done is no longer pressed as a dismiss key and the form no
longer submits. The iPad hide-keyboard key and a Done toolbar above the keys stay
dismiss keys.

Closes #4640

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The keyboard help now says keyboard enter submits, so "submit" in its search keywords repeats
the description, which the search-keyword guard forbids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The checkout replays, the iOS perf form step and the test-app copy dismissed on
a field whose only Done key is its return key, which keyboard dismiss now
refuses. returnControl also ignores an accessory toolbar's button above the
first key row.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Rebased onto main (#4642 changed the keyboard-key helper to observedKeyboardKeys(in:), which broke the merged macOS and iOS test builds) and pushed. The dismiss lookup reads the return key through that snapshot helper, one keyboard snapshot per call (observedKeyboardKeys(app:) wraps it and returns nothing off iOS).

On the rebased head, on the iPhone Air simulator (iOS 27.0, 1B89356B):

  • the macOS and iOS runner test targets build locally;
  • the 20 return-key tests and the 4 keyboard device tests pass, 0 failures;
  • both replays pass (02-checkout-release.ad 19 steps in 43.6s, checkout-form.ad 19 steps in 14.8s);
  • the Wallet repro still refuses with keyboard_dismiss_unavailable and dispatched: no, and the sign-up form stays.

@thymikee
thymikee force-pushed the t3/ios-keyboard-dismiss-return-key branch from 05f4467 to 1831b06 Compare November 17, 2026 16:17
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 4 new findings on 1831b06. The verdict and the full list are in the summary comment.

…n key

One pure rule (RunnerKeyboardStatus.mayDismiss) admits a dismiss control from one keyboard
snapshot: a hide-keyboard key always, a Done only when it is proven to be an accessory button
above the character key rows. A failed read or a keyboard without a character-key anchor presses
no Done. returnControl names a wording match only inside the key rows, so status and dismiss
share the same band.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on 5027d82. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The code-side asks from the earlier review (#4644 (comment)) are fixed at 5027d82, but the rewritten dismiss tap path has no live run yet.

CI is nearly done: one review check is still open; Numeric Ranges and Coverage have passed. Smoke Tests (ios) passed on the merge of 5027d82 into 945b1f0 (b2c8e29) and ran smoke:form-input, which covers the dismiss refusal and keyboard enter on field-email. The runner keyboard XCUITests and the new unit tests were not run in CI, which executed 6 unrelated tests. There are no conflicts.

The delta rewrote the live dismiss path in RunnerTests+Keyboard.swift. It reads one keyboard snapshot, admits controls through the new mayDismiss gate (character-row anchor, 80pt reach), drops the exists/isHittable check for in-keyboard controls, and taps a coordinate normalized to the keyboard frame. The device run in the PR body is from fc45a00, so nothing live shows a positive dismiss still lands at this head. A wrong offset, or a toolbar Done the anchor misjudges, would make dismiss refuse or tap the wrong spot on fields that dismissed before. Please run testKeyboardDismissPressesTheDoneToolbarNotTheDoneReturnKey, testKeyboardDismissNeverPressesADoneReturnKey and testKeyboardDismissTapsItsDismissKeyWhileTheAppIsBusy on an iOS simulator at 5027d82. Also run the Wallet password-field repro (it refuses and the form stays), and one positive dismiss through the CLI, via an accessory Done or the iPad Hide keyboard key, that shows dismissed: true and mechanism: dismissKey. Please post the outputs.

Not blocking, and fine to take or leave: mayDismiss admits "Hide keyboard"/"Dismiss keyboard" without a frame check (RunnerKeyboardStatus.swift:97), so the descendants fallback can tap an app button with that label anywhere on screen, and the same 80pt reach as for Done would close that; the help text (packages/command-surface/src/system/index.ts:322 and commands.md:947) could add that when the key rows cannot be read, no Done is pressed and dismiss refuses with keyboard_dismiss_unavailable; and keyboardStatus could call the new readKeyboard (RunnerTests+Keyboard.swift:150), which repeats its iOS read, and map nil to visible: false.

The four earlier inline threads no longer apply and can be resolved: the Done fail-closed case is fixed at 5027d82 (discussion_r4602599426), the 2pt return-control comparison is deleted (#4644 (comment)), the nine element queries are gone (#4644 (comment)), and the unanchored return-control case is fixed (#4644 (comment)).

thymikee and others added 2 commits November 17, 2026 18:01
… its frame

A snapshot control outside the keyboard's frame is tapped through its own element, never through a
negative normalized offset. Hide-keyboard controls get the same reach check as Done, keyboardStatus
reuses readKeyboard, and the help and commands.md state that an unreadable key row refuses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding and 1 moved to a new line on 1382109. The verdict and the full list are in the summary comment.

thymikee and others added 2 commits November 17, 2026 18:15
The hide-keyboard key sat at iPad coordinates under a phone keyboard frame, so the reach check
rightly refused it. The fixture now carries a matching keyboard frame.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…keys only

A dismiss control is tapped through its live element, found uniquely by wording and type among the
keyboard's controls, never through a coordinate from a snapshot the keyboard may have moved since;
an ambiguous control refuses. The key-row anchor takes key-type controls only, so a one-letter
QuickType candidate cannot pull it up to the prediction bar.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

thymikee commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

Live run at head caf095a29351cf9c43a6fd300dd5f08d6d7d75d3 (iPhone Air simulator, iOS 27.0, 1B89356B, this branch's CLI and runner).

Runner XCUITests (xcodebuild test-without-building, the three you named plus the keyboard enter test and the two new identity and QuickType unit tests):

testKeyboardDismissNeverPressesADoneReturnKey] passed (11.356 seconds).
testKeyboardDismissPressesTheDoneToolbarNotTheDoneReturnKey] passed (11.039 seconds).
testKeyboardDismissTapsItsDismissKeyWhileTheAppIsBusy] passed (9.991 seconds).
testKeyboardDismissTapsOnlyAControlItCanTellApart] passed (0.015 seconds).
testKeyboardEnterPressesReturnWhileTheAppIsBusy] passed (8.724 seconds).
testKeyboardRowAnchorIgnoresAOneLetterQuickTypeCandidate] passed (0.146 seconds).
Executed 28 tests, with 0 failures (0 unexpected) in 44.873 (44.900) seconds

The 23 pure return-key tests also pass on the macOS host lane (Executed 23 tests, with 0 failures).

Wallet password field (sign-up, focus in the password field, return key done):

$ agent-device keyboard status --json
  "data": {
    "platform": "ios",
    "action": "status",
    "visible": true,
    "returnKey": "done",
    "returnKeyLabel": "done"
  }
}

$ agent-device keyboard dismiss --json
  "success": false,
    "code": "UNSUPPORTED_OPERATION",
          "code": "KEYBOARD_DISMISS_UNAVAILABLE",
      "runnerErrorCode": "KEYBOARD_DISMISS_UNAVAILABLE",
      "reason": "keyboard_dismiss_unavailable",
      "dispatched": "no",

$ agent-device snapshot -i (head)
Page: com.expo-explore.example.wallet
App: com.expo-explore.example.wallet
Snapshot: 61 visible nodes
@e1 [application] "Wallet"
@e2 [button] "Back"
@e3 [scroll-area] [scrollable]
  [content below scroll-area hidden]
@e4 [text] "Create your account"
@e5 [text] "It takes less than a minute."
@e6 [text] "Full name"
@e7 [text-field] "Review User" [editable]
@e8 [text] "Email"

$ agent-device keyboard status --json (after the refusal)
  "data": {
    "platform": "ios",
    "action": "status",
    "visible": true,
    "returnKey": "done",
    "returnKeyLabel": "done"
  }
}

Positive dismiss on the runner fixture's accessory-Done screen (--agent-device-keyboard-done-return accessory: a field whose return key is also Done, plus a Done toolbar). The answer label reads Accessory, not Submitted, so the toolbar was pressed and the return key was not:

$ agent-device keyboard status --json
  "data": {
    "platform": "ios",
    "action": "status",
    "visible": true,
    "returnKey": "done",
    "returnKeyLabel": "done"
  }
}

$ agent-device snapshot -i (keyboard up, head)
@e3 [text-field] "hello" [focused] [editable]
@e4 [text] "Unanswered" [covered]
@e6 [button] "Done"
@e12 [button] "I"
@e13 [button] "The"
@e14 [button] "I’m"
@e55 [button] "Next keyboard"
@e56 [button] "Dictate"

$ agent-device keyboard dismiss --json
{
  "success": true,
  "data": {
    "platform": "ios",
    "action": "dismiss",
    "wasVisible": true,
    "dismissed": true,
    "visible": false,
    "mechanism": "dismissKey",
    "message": "Keyboard dismissed via its dismiss key"
  }
}

$ agent-device snapshot -i (after dismiss)
@e3 [text-field] "hello" [editable]
@e4 [text] "Accessory"

$ agent-device keyboard status --json (after dismiss)
  "data": {
    "platform": "ios",
    "action": "status",
    "visible": false
  }
}

The CLI sessions are closed.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on caf095a. The verdict and the full list are in the summary comment.

…control

The keyboard, its key rows and any accessory Done are read from one app snapshot, so no decision
compares a live frame with snapshot geometry. Eligible controls are tried in preference order and
the first that is unique by type, label and identifier, in the snapshot and in one live lookup, is
tapped; dismiss refuses only when none resolves.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Live re-check at head 4e6fca1c58 (iPhone Air, iOS 27.0): the Wallet password field still refuses keyboard dismiss with keyboard_dismiss_unavailable and dispatched: no and the sign-up form stays, and on the fixture's accessory-Done screen keyboard dismiss returns dismissed: true, mechanism: dismissKey with the answer label Accessory (toolbar pressed, return key not). Runner tests at this head: 29 of 29 on the simulator including the toolbar, never-presses and busy tests, and 24 of 24 pure tests on the macOS host lane.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on 4e6fca1. The verdict and the full list are in the summary comment.

…ntifier as empty

The live dismiss element must exist and be hittable; a covered control is passed over for the next
eligible one and dismiss refuses when none is tappable. A control with no identifier is looked up by
label alone, and a nil and an empty identifier are one thing in the uniqueness check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. This review covers 4e6fca1; 0ef27cb landed while it ran and gets its own delta review. At 4e6fca1 the fail-closed anchor, the identity-based tap and the try-each loop are in, and the earlier concerns about frame matching and QuickType anchors are fixed. One regression remains, so this is not ready to merge yet.

A sheet or form can show a navigation-bar Done while the focused field's input accessory toolbar also has a Done, with the same label and identifier. readKeyboardSurface collects dismiss-worded buttons from the whole app snapshot, and isUniqueDismissControl counts all of them, not only the controls near the keyboard. The toolbar Done is then not unique and is dropped. The live lookup by label and identifier would also match two buttons and refuse. On main this screen dismissed, so it now fails with keyboard_dismiss_unavailable and nothing is dispatched. It never submits the form, but the help text promises that a Done toolbar above the key rows still dismisses. The rule to satisfy: identity must name exactly one control among the controls that belong to the keyboard, in both the snapshot and the live lookup. Reading only the keyboard's host window, which holds the keyboard and its accessory but not the navigation bar, would do that. Applying uniqueness only to controls that pass isNearKeyboard would also work. Please add a unit fixture with a far-away Done button next to a toolbar Done.

Not blocking, and you can take or leave it: readKeyboardSurface takes a full app.snapshot() wrapped in try?, so a deep or slow tree gives a nil surface and refuses even when the iPad Hide keyboard key is present, and it pays a full-tree capture on every dismiss. Scoping the read to the host window removes this as well.

Could one read of the keyboard's host window be simpler? Decide eligibility on it with the existing mayDismiss, then tap through a live query scoped to the same window and matched by identity. That drops the app-wide walk and the global uniqueness filter, and isNearKeyboard becomes a sanity check only. First, please confirm on iOS 27 that the accessory view and the keyboard element share one window in the XCUITest tree. If they do not, keep the app snapshot and apply uniqueness only among near-keyboard controls.

The required live evidence is in, but it is a prose summary at this head. The raw outputs are from caf095a, before the app-wide snapshot and the try-each loop landed.

There are no conflicts. 20 of 21 checks pass and one is still in progress. CI does not run the runner keyboard XCUITests, so green checks will not cover this tap path. Before merge, fix the Done case and post a re-run of the toolbar dismiss at the new head.

These open threads no longer apply, so please resolve them: r4602599426 (Done now fails closed with no anchor), r4602599446 (the 2pt frame comparison is deleted), r4602599457 (per-label queries are gone), r4602599474 (unanchored case returns false, covered by a test), r4602899825 (a Done above the key rows is admitted), r4603135385 (no snapshot-coordinate tap remains), r4603135399 (QuickType buttons no longer anchor), r4603368212 (eligibility comes from one snapshot), and r4603368661 (the tap loop tries the next control).

…ntrol apart

A navigation bar's Done with the same label and identifier no longer makes the toolbar Done
ambiguous. Uniqueness is judged among controls near the keyboard, and the live lookup, which finds
every control with that identity, takes the control by its position among them after a count check
against the snapshot. The fixture's accessory screen carries a far-away Done to exercise it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Live re-check at head a16c5ae9d4b5714dcf589dd9cec10e1d7cbd56ef (iPhone Air simulator, iOS 27.0, 1B89356B, this branch's CLI and runner).

Wallet password field and the toolbar dismiss (the fixture screen has a screen-level Done at the top, far from the keyboard, with the same label as the toolbar Done; the return key is also Done):

--- Wallet password field: agent-device keyboard dismiss --json
  "success": false,
      "reason": "keyboard_dismiss_unavailable",
      "dispatched": "no",
--- snapshot -i
@e4 [text] "Create your account"
--- fixture screen (screen-level Done + toolbar Done + Done return key)
@e2 [button] "Done"
@e4 [text-field] "Return key is Done" [editable]
@e5 [text] "Unanswered"
--- agent-device keyboard dismiss --json
  "success": true,
    "dismissed": true,
    "visible": false,
    "mechanism": "dismissKey",
--- snapshot -i after dismiss
@e5 [text] "Accessory"

The answer label Accessory shows the toolbar Done was pressed; the screen Done would set Screen and the return key Submitted.

Tests at this head: 31 of 31 on the simulator (including the toolbar, never-presses, covered-control, far-away-Done and busy tests) and 26 of 26 pure tests on the macOS host lane.

Dismiss cost (refused keyboard dismiss through the CLI, wall time per call, 8 calls per batch, two batches per build, iPhone Air iOS 27.0; before = 5027d82 in a separate worktree, after = this head; the CLI process and daemon round trip are included in both):

Screen Before 5027d82 (ms, mean of two batches) After a16c5ae (ms, mean of two batches)
Wallet password field (61-node tree) 665 and 544 307 and 323
Settings search field (78-node tree) 381 and 365 427 and 386

On the Wallet screen the app snapshot is faster than the keyboard snapshot plus the per-control queries it replaced. On Settings, the deepest screen I could drive, it costs about 35 ms more (roughly 9%). I did not measure a pathological tree such as the 65-level heavy feed, so a very deep tree may cost noticeably more; a failed or slow read still refuses and never presses.

On iOS 27 the accessory toolbar and the keyboard are in different windows of the live tree (the toolbar's Done is in one window, the keyboard in another), so a read of the keyboard's host window cannot hold the toolbar. The app snapshot stays, and identity is now judged only among controls near the keyboard.

@thymikee

Copy link
Copy Markdown
Member Author

Live results at head 12c81e1dc97d25a5713eb0d9439e9ccabaa8ba47 (this branch's CLI and runner; iOS 27.0; the Wallet app and the runner's fixture host app).

iPhone Air (1B89356B):

--- Wallet password field (return key Done): keyboard dismiss --json
  "success": false,
      "reason": "keyboard_dismiss_unavailable",
      "dispatched": "no",
@e4 [text] "Create your account"
--- fixture accessory (screen Done far away + accessory Done + Done return key): keyboard dismiss --json
  "success": true,
    "dismissed": true,
    "visible": false,
    "mechanism": "dismissKey",
@e5 [text] "Accessory"
--- fixture plain-accessory (screen Done far away + accessory Done + Done return key): keyboard dismiss --json
  "success": true,
    "dismissed": true,
    "visible": false,
    "mechanism": "dismissKey",
@e5 [text] "Accessory"
--- deep-tree fixture (70 nested groups, field focused): keyboard dismiss --json
  "success": false,
          "cause": "tree_unreadable",
      "reason": "keyboard_dismiss_unavailable",
      "dispatched": "no",
      "cause": "tree_unreadable",

The fixture screens carry a screen-level Done with the accessory's label, far from the keyboard; accessory builds the accessory from a UIToolbar and plain-accessory from a plain UIView holding a UIButton. The answer label Accessory shows the accessory Done was pressed. The deep-tree fixture nests the field 70 groups deep, past what app.snapshot() can read: the keyboard's own read finds no dismiss key, and the refusal names the unreadable tree.

iPad (A16, A14201BD), name field focused, software keyboard up (screenshot before shows it, after shows it gone, form intact):

--- iPad (A16) iOS 27.0, name field focused, keyboard visible: keyboard dismiss --json
  "success": true,
    "wasVisible": true,
    "dismissed": true,
    "visible": false,
    "mechanism": "dismissKey",
@e8 [text-field] "Review User" [editable]
@e10 [text-field] "Email" [editable]
    "visible": false

A first attempt returned wasVisible: false because it ran before the keyboard had appeared; the one above waited for keyboard status to report visible: true first.

Tests at this head: 30 of 30 on the iPhone Air, including the toolbar, plain-view accessory, never-presses and busy tests, and 24 of 24 pure tests on the macOS host lane. I did not add an automated iPad XCUITest: the nightly lanes select by device, and a test that skips on iPhone would not fit them, so the iPad hide key is covered by the pure fixture (testKeyboardDismissNeverPressesADoneInsideTheKeyRows, ...IdentifierOnlyHideKey) and the live run above.

Refused-dismiss timing (CLI wall time per call, 8 calls per batch, two batches per build, iPhone Air; before = 82b24c6, after = 12c81e1):

Screen Before 82b24c6 (ms, per-batch means) After 12c81e1 (ms, per-batch means)
Wallet password field 262 and 251 254 and 255
Settings search field (78 nodes) 336 and 311 336 and 315

No change, as expected: the read is the same whole-app snapshot.

Diff size against the merge base: +665 −102 over 21 files (82b24c6 was +723 −93 over 16). The production Swift is small; most of the lines are tests and the device fixture.

@thymikee

Copy link
Copy Markdown
Member Author

Reply to the Chief of Staff review at 82b24c6, fixed at 12c81e1dc97d25a5713eb0d9439e9ccabaa8ba47. Raw live outputs are in the run comment.

Root cause fixed. Ownership is no longer scoped by element type. The Container enum, the position-in-query mapping, uniqueDismissControls, isUniqueDismissControl, dismissLabel, lookupFormat, firstTappable and mayDismiss are gone. One function, RunnerKeyboardStatus.dismissControls(in:), lists the dismiss-worded controls (label or identifier) near the keyboard: inside its frame or within 80 pt above it. Never the identified return key. Inside the keyboard a Done needs the letter-row anchor and sits above it, so it fails closed without one. An accessory wholly above the keyboard needs no anchor. An identity (type, label, identifier) must name exactly one control among the near-keyboard controls, so a header or top-toolbar Done far away no longer counts.

Live lookup. Each candidate is looked up by identity, the matches kept are those near the keyboard, and it is tapped only when exactly one remains and it is hittable. Candidates are tried in preference order and dismiss refuses only when none qualifies.

Also done: identifier-only controls stay candidates (an empty-label Hide keyboard key). If the whole-app snapshot fails, the keyboard's own snapshot answers, so the iPad hide key still works. When that fallback finds nothing, the refusal carries details.cause: "tree_unreadable" next to keyboard_dismiss_unavailable, wired through the runner error payload and buildRunnerResponseError and documented in the keyboard help, commands.md and the runner protocol note. A fixture that nests the field 70 groups deep triggers it live.

Tests. I removed the predicate-string assertion and the keys == nil hide case. New unit cases cover an accessory beside a far same-label Done, a keyboard with no character keys, an accessory between QuickType and the letter row, an identifier-only hide key, twin controls, and the unreadable-tree refusal. Device fixtures cover a toolbar accessory and a plain UIView + UIButton accessory, each beside a far Done. The iPad hide key is covered by the pure fixtures and a live run, not an automated iPad test.

…ntract

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

CI on 12c81e1 failed testErrorPayloadEncodesEveryFieldButTheRunnerInternalRetryableFailure: the every-field fixture did not set the new cause field. It now does, and the test expects the key. testTargetAppUnavailableErrorKeepsItsWireShape still holds: a nil cause is not encoded. I ran the whole models test file with the keyboard pure tests on the macOS host lane before pushing (34 of 34), having selected only the keyboard tests last time.

@apex-sentinel-staging

This comment has been minimized.

When the whole-app snapshot succeeds but carries no keyboard node, as a tree too deep to serialize
comes back, the keyboard's own read answers, so its hide-keyboard key is still pressed, and a
refusal that finds nothing there carries details.cause tree_unreadable.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Live re-check at head 4c0b0690c592d7832d7dc3336efb1bd8ee63e2be (iOS 27.0, this branch's CLI and runner).

iPhone Air (1B89356B), deep-tree fixture (the field nested 70 groups deep, focused, return key return; no dismiss key exists, and the app snapshot cannot read the tree):

--- iPhone Air, deep-tree fixture (70 nested groups, field focused): keyboard dismiss --json
  "success": false,
          "cause": "tree_unreadable"
      "reason": "keyboard_dismiss_unavailable",
      "dispatched": "no",
      "cause": "tree_unreadable",

iPad (A16, A14201BD), name field focused after keyboard status reported visible: true:

--- iPad (A16) iOS 27.0, name field focused, keyboard visible: keyboard dismiss --json
  "success": true,
    "wasVisible": true,
    "dismissed": true,
    "visible": false,
    "mechanism": "dismissKey",
@e8 [text-field] "Review User" [editable]
@e10 [text-field] "Email" [editable]
    "visible": false

Tests at this head: 41 of 41 on the iPhone Air (the new fallback case, the toolbar and plain-view accessory tests, the never-presses and busy tests) and 34 of 34 on the macOS host lane (the whole models file plus the keyboard tests). The new case, testAppSnapshotWithoutAKeyboardFallsBackToTheKeyboardsOwnRead, builds an app snapshot with no keyboard node beside a keyboard read that has a Hide keyboard key: the hide key is the control pressed, the tree counts as unreadable, and with no keyboard read either the surface is nil and the refusal carries the cause.

The deep-tree fixture and the iPad cannot be combined here: the fixture host app is not installed on the iPad simulator, so the case where the app snapshot omits the keyboard and the iPad hide key is the only control is covered by that unit test, not live.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

@apex-sentinel-staging review

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At 4c0b069 the problem from my earlier review (#4644 (comment)) is fixed for every accessory shape, and I found no new problem in the code. This rests on the live plain-accessory, deep-tree and iPad outputs you posted. The plain-accessory CLI run is from 12c81e1. Its path is the same at 4c0b069 apart from the no-keyboard-node branch, and you report that the plain-view XCUITest passed at 4c0b069. An RN InputAccessoryView was not run, and the plain UIView + UIButton fixture stands in for it. That is fine, because the position rule does not depend on the element type.

Not blocking, take or leave: at RunnerTests+Keyboard.swift:604, none becomes .treeUnreadable whenever the fallback read answered. If that read held a dismiss control, such as the iPad Hide keyboard key, but the live lookup found it not hittable or ambiguous, the error says the keyboard exposes no dismiss key and sets details.cause to tree_unreadable. That cause is defined as "the keyboard's own read held no dismiss key", so it should be .treeUnreadable only when the fallback surface is nil or dismissControls(in: surface) is empty, and .notFound otherwise.

Do you need the cause field at all? Could you keep the fallback in resolveKeyboardSurface and drop cause with its plumbing (KeyboardDismissTap.treeUnreadable, RunnerKeyboardDismissOutcome.treeUnreadable, ErrorPayload.cause, the runner-contract.ts branch and test, and the help, commands.md and protocol sentences), so tapKeyboardDismissControl returns Bool again? If a caller needs it, gating it as above is enough. This is a question, not a condition for merge.

The two earlier inline threads on the fallback (#4644 (comment)) and on the same-identity Done (#4644 (comment)) no longer apply. The first is fixed in resolveKeyboardSurface, which now falls back when the app root has no keyboard node, and it is covered by KeyboardReturnKeyTests.swift:428. The second is fixed because identity is now counted among near-keyboard controls only. Please resolve both.

20 of 21 checks pass and one is still queued, not failed. CI does not run the runner keyboard XCUITests, so tapKeyboardDismissControl is covered only by your live runs. There are no conflicts. Nothing else blocks merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 17, 2026
…miss candidate

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 4c0b069. The verdict and the full list are in the summary comment.

Comment thread scripts/perf/suite.ts Resolved
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Live re-check at head 5a1b7c0e89a013e6b2a9e93ebd381234b07dc5d6 (iPhone Air, iOS 27.0, 70-deep fixture, field focused, no dismiss key): "success": false, "cause": "tree_unreadable", "reason": "keyboard_dismiss_unavailable", "dispatched": "no", "cause": "tree_unreadable",. The refusal still names the unreadable tree. macOS host lane at the previous push: 34 of 34 (models file plus keyboard tests), and the fallback and plain-view device tests pass on the simulator. This head also gates cause so it is set only when the fallback held no dismiss candidate (refusalIsTreeUnreadable, unit-tested for an empty fallback, a fallback with a candidate the live lookup rejects, and a readable tree), and keeps the perf step id keyboard-dismiss.

@apex-sentinel-staging

This comment has been minimized.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 17, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At 5a1b7c0 the earlier code concerns are fixed, including the keyboard fallback in resolveKeyboardSurface (covered by KeyboardReturnKeyTests.swift:428-453), and one help claim is still wrong. All 21 CI checks pass, and there are no conflicts.

The new help says that when the key rows cannot be read, dismiss refuses with keyboard_dismiss_unavailable (system/index.ts:322, commands.md:947). The code does not always refuse. With a readable keyboard frame but no character-key anchor, dismissControls still admits Hide keyboard/Dismiss keyboard. It also admits a unique near Done whose maxY is at or above keyboard.frame.minY, because canBeReturnKey is false there (RunnerKeyboardStatus.swift:191-196). The noCharacterKeys accessory test requires this, and a unique live match is then tapped (Keyboard.swift:620-622). Agents reading the help may skip a supported dismiss route, or expect a refusal where an accessory tap happens. Please qualify both texts: without a readable key-row anchor, Done controls inside the keyboard are refused, while hide controls and Done accessories wholly above the keyboard can still be used. The classifier is right as it is, so please do not change it to match the sentence.

The two other review threads do not need more work: the suite id one is intended, because the id keeps Android's history and suite.ts:304-307 documents the iOS shift (thread); the keyboard fallback one is fixed at this commit (thread). Please resolve both.

CI does not run the runner keyboard XCUITests, so their result rests on your report. No live run reaches the new notFound branch, since that state cannot be produced on demand. It changes only the cause in the refusal, never what is tapped, so I do not count it against merge. Once the help text is fixed, nothing else stops this from merging.

…ble key row

Without a character-key anchor, dismiss refuses only a Done inside the keyboard; the hide-keyboard
key and a Done accessory wholly above the keyboard still dismiss, as the classifier and its tests
already require. The help and commands.md said dismiss refused outright.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Help-text fix from the review at 5a1b7c0 is in 5417b02. The `keyboard` help (`packages/command-surface/src/system/index.ts`) and `website/docs/docs/commands.md` now say that without a readable key row, dismiss refuses only a Done inside the keyboard, while the hide-keyboard key and a Done wholly above the keyboard still dismiss. That matches the classifier and the no-character-keys test; the classifier is unchanged. The MCP tool-loading guards, `check:doc-prose` and `check:command-docs` pass. The suite-id thread (intended) and the keyboard-fallback thread (fixed) are resolved.

🤖 Generated with Claude Code

@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 5417b02

Since the review of 5a1b7c0: 0 new · 0 still open · 0 no longer raised

No open findings. 1 withdrawn by a re-check since this review.

3 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (655ede2796e5).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

I reviewed 5417b02 and found no code problems. The help-text issue from the earlier review (#4644 (comment)) is fixed. The change since then touches one help string and one docs bullet, and no code route changed. All 21 checks pass, and there are no conflicts. The live runs posted earlier still cover the classifier, because this delta changes only text. No review threads are open. Nothing else needs to happen before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 17, 2026
@thymikee
thymikee merged commit eec775c into main Nov 18, 2026
25 of 26 checks passed
@thymikee
thymikee deleted the t3/ios-keyboard-dismiss-return-key branch November 18, 2026 08:52
thymikee added a commit that referenced this pull request Nov 19, 2026
…g Return key (#4768)

keyboard dismiss on iOS refuses a visible keyboard it cannot hide. On a
search field the useful next step is usually Return, but the hint named
only the Hide Keyboard key and a pan gesture. The refusal now reads the
Return key its own status already observed and, for search, go, done and
send, names keyboard enter and what it will do. Dismiss still never
presses Return (#4644).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS keyboard dismiss presses a "Done" return key and submits the form

1 participant